//
//  GBaseTableViewController.swift
//  sinaWeiBoAI
//
//  Created by Z.J on 16/3/20.
//  Copyright © 2016年 Z.J. All rights reserved.
//

import UIKit




class GBaseTableViewController: UITableViewController {

    // 判断是否进入访客视图
    var userLogin = false
    
    override func loadView() {
        
        userLogin ? super.loadView() : setupLoadView()
    }
    
    private func setupLoadView()
    {
        vistorView = GVistorView()
        
        view = vistorView
        
        // 判断当前是哪个控制器
        if self is GProfileViewController
        {
            vistorView?.setupVisitorInfo("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }else if self is GHomeViewController
        {
            vistorView?.startRotationAnimation()
        }else if self is GMessageViewController
        {
            vistorView?.setupVisitorInfo("visitordiscover_image_message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        }else if self is GDiscoverViewController
        {
            vistorView?.setupVisitorInfo("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        }
        
        // 设置代理
        vistorView?.vistorViewDelegate = self
        
        // 设置访客视图
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)
    
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }
    
    

    //MARK: - 懒加载
     private var vistorView : GVistorView?
}



// MARK: - CZBaseTableViewController 扩展,实现 CZVistorViewDelegate 协议
// 扩展,和oc category类似, estension 可以实现协议, 方便代码统一管理

extension GBaseTableViewController: GVistorViewDelegate
{
    func vistorViewRegister()
    {
       
    }
    
    func vistorViewLogin()
    {
        // 跳转界面
        let oauthVC = GOauthViewController()
        
        presentViewController(UINavigationController(rootViewController: oauthVC), animated: true, completion: nil)
    }
}

